package com.zht.controller;

import com.zht.common.Result;
import com.zht.pojo.dto.LoginReqDTO;
import com.zht.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sms")
public class SmsController {

    private final SmsService smsService;

    @Autowired
    public SmsController(SmsService smsService) {
        this.smsService = smsService;
    }

    @PostMapping("/sendCode")
    public Result<Void> sendCode(@RequestBody LoginReqDTO request) {
        // 从 DTO 中获取 phone
        smsService.sendVerificationCode(request.getPhone());
        return Result.ok();
    }

    @PostMapping("/sendFakeCode")
    public Result<Void> sendFake(@RequestBody LoginReqDTO request) {
        // 从 DTO 中获取 phone
        smsService.sendFakeCode(request.getPhone());
        return Result.ok();
    }
}